package com.fz.consumer.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MqListener2 {
    // 直接注解定义，这样可以不需要写多个绑定
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "direct6.queue1"),
            exchange = @Exchange(name = "hmall.direct6", type = ExchangeTypes.DIRECT),
            key = {"red", "blue"}
    ))
    public void listenDirectQueue6(String msg){
        log.info("消费1接收到direct6.queue1的消息：{}",msg);
    }

    @RabbitListener(bindings = @QueueBinding(
        value = @Queue(name = "direct6.queue2"),
        exchange = @Exchange(name = "hmall.direct6"),
        key = {"red","yellow"}
    ))
    public void listenDirectQueue62(String msg){
        log.info("消费1接收到direct6.queue2的消息：{}",msg);
    }
}
